SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


-- =============================================
-- Author:		<Sebastian Wright>
-- Create date: <13/12/2010>
-- Description:	<Elimina el usuario solicitado.>
-- =============================================
CREATE PROCEDURE [dbo].[wp_elimina_usuario]
	(
		@operador _codigo_largo
	 )
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;		
	
	DECLARE @userid uniqueidentifier
	
	DELETE FROM wad_terminales WHERE cd_operador = @operador
	
	DELETE FROM dbo.wld_miembros_grupo WHERE cd_operador = @operador

	DELETE FROM dbo.wad_operadores WHERE cd_operador = @operador
		
	SELECT @userid = userid FROM dbo.aspnet_users WHERE username = @operador	

	DELETE FROM dbo.aspnet_membership WHERE userid = @userid    

	DELETE FROM dbo.aspnet_users WHERE username = @operador
	
END


GO
